package com.command
{
	import com.services.IService;
	import com.services.ServiceLocator;
	import com.vo.ICPObjectsVO;
	import com.vo.ValueObject;
	
	import mx.controls.Alert;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.remoting.mxml.RemoteObject;
	import mx.utils.ObjectUtil;

	public class ICPObjectsDeleteCommand implements IService, IResponder
	{		
		public function execute(valueObject:ValueObject):void
		{			
			var service:RemoteObject = ServiceLocator.getInstance().getRemoteObject("ICPObjectsService");
			var token:AsyncToken = service.deleteRecord(ICPObjectsVO(valueObject).objectID);
			token.addResponder(this);
		}
		
		public function result(data:Object):void
		{
			Alert.show("Deleted successfully");	
		}
		
		public function fault(info:Object):void
		{
			Alert.show("Error \n"+ObjectUtil.toString(FaultEvent(info).fault));
		}
		
	}
}